import Vue from 'vue'
import Router from 'vue-router' //路由模块
import Home from './views/Home.vue' //主页组件
//import my from './views/my.vue'
import Playing from './views/Playing.vue'
import Comming from './views/Comming.vue'

//Vue.use()     添加模块，添加功能
Vue.use(Router)

//单页应用  single page app(SPA)

 let rou= new Router({
	linkExactActiveClass:'addLink',
	//mode: 'history',
	//base: process.env.BASE_URL,
	routes: [ //路由配置（以往的页面）
		{
			path: '/',
			redirect: "/home"
		},
		{
			path: '/home', //默认路径        "/"代表默认路径     路径小写
			name: 'home', //name 并不是必须的,命名路由
			component: Home, //访问到路由时,渲染的组件（页面） 
			children: [{
					path: "playing",
					component: Playing
				},
				{
					path: "comming",
					component: Comming
				},
				{
					path: "",
					redirect: 'playing'
				}
			]
		},
		{
			path: '/shows/:cinemaId',
			name: 'shows',
			component: () =>
				import('./views/Shows.vue')
		},
		//  {
		//    path: '/about',
		//    name: 'about',
		//    // route level code-splitting
		//    // this generates a separate chunk (about.[hash].js) for this route
		//    // which is lazy-loaded when the route is visited.
		//    
		//    //路由被访问时才进行加载（路由懒加载）   打包时会分离对应的文件
		//    component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
		//  },
		//  {
		//  	path:'/my',
		//  	name:'my',
		// 	 component: () => import('./views/my.vue')
		// 	 
		// 	},
		// 	{
		// 		//动态路由
		// 		path:'/my/:userId',
		// 		name:'my',
		// 		component:() => import('./views/my.vue')
		// 	},
		{
			path: '/movie/:movieId',
			name: 'movie',
			component: () =>
				import('./views/Movie.vue')
		}
	]
})

// rou.beforeEach((to, from, next) => {
// 	//to and rom are Route Object(都是路由对象),next() must be called to resolve  the hook(必须被调用才能触发钩子函数)

// 	console.log('from',from)
// 	console.log('to',to)
// 	next()
//   })

  export default rou